<?php

namespace App\Api\Controllers;

use App\Models\Test_config;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use DB;

class Get_squad_testController extends Controller
{
    public function get_squad_test(Request $request)
    {
        $SquadId = $request->get('q');
        $list = DB::table('test_configs')         //将两张表拼接起来
			->join('test_assigns', function($join)
			{
			    $join->on('test_assigns.test_config_id', '=', 'test_configs.id');
			})->where('Test_configs.status','0')->where('test_assigns.squad_id',$SquadId)->select('test_configs.id','test_configs.name','test_configs.status')
				->get(['id', DB::raw('name as text')]);
		foreach ($list as $key => $value) {
            $arr[] = array("id" => $value->id, "text" => $value->name);
        }
		return $arr;
    }
}
